<?php
set_time_limit(7200);
include("db.inc");

$timestamp = time();

$first_month=05;
$first_year=2011;

$this_month = date("m",$timestamp);
$this_year = date("Y",$timestamp);

echo "
<table border='1'>
<tr>
<th>Datum</th>
<th>Anzahl</th>
</tr>

";
for($i=$first_year; $i<=$this_year; $i++)
{
	if($i!=$this_year)
	{
		$limit_month=12;
	}
	else
	{
		$limit_month=$this_month;
	}
	for($j=$first_month; $j<=$limit_month; $j++)
	{
		$sql = "SELECT * FROM rec r, book b WHERE r.IDENT = b.IDENT AND b.MWST = 3 AND r.GES_BRUTTO < 30 AND r.ADR_LAND = 1 AND MONTH(r.DAT_PRINT) = $j AND YEAR(r.DAT_PRINT) = $i";
		$result = $dbw->query($sql);
		if ($result)
		{
			$row_cnt = $result->num_rows;
			echo"
			<tr>
				<td align='center'>".$i."-".$j."</td>
				<td>".$row_cnt."</td>
			</tr>
			";

		}
	}
	$first_month =1;
}

echo "</table>";




$result->close();
unset($result);

?>